﻿using EnvDTE;
using ClassMedataBrowser.Domain;
using EnvDTE80;
using Microsoft.VisualStudio.TextManager.Interop;
using System.Runtime.InteropServices;
using System;
namespace ClassMetadataBrowser.Domain
{
	public class ProjectFile
	{
		public string ProjectName
		{
			get;
			set;
		}

		public string Name
		{
			get;
			set;
		}

		public string FilePath
		{
			get;
			set;
		}

		public ProjectItem ProjectItem
		{
			get;
			set;
		}

		[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
		internal static extern IntPtr SetFocus(IntPtr hwnd);

		public void Open()
		{
			//Window window = ProjectItem.Open(Constants.vsViewKindCode);
			//window.Activate();

			//ProjectItem.DTE.ExecuteCommand("open", ProjectItem.Name)

			try
			{
				((DTE2)ProjectItem.DTE).ItemOperations.OpenFile(ProjectItem.get_FileNames(0), "{00000000-0000-0000-0000-000000000000}");
			}
			catch (Exception)
			{
				// todo(0): log exception
			}

		}
	}
}
